Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore non-explicit NEVER in purity check #3243

Merged
merged 6 commits into from
Jul 16, 2024

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 15, 2024

@staabm staabm changed the title Ignore non-explicit NEVER in purity check when treatPhpDocTypesAsCertain=false Ignore non-explicit NEVER in purity check Jul 15, 2024
if ($exprType->isCallable()->yes()) {
if (
$exprType->isCallable()->yes()
&& (!$exprType instanceof NeverType || $exprType->isExplicit())
Copy link
Contributor Author

@staabm staabm Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a different way to fix this would be to make NeverType return a different acceptor on getCallableParametersAcceptors when non-explicit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would make more sense to me. It's basically never going to be called so a special class instead of TrivialParametersAcceptor would be welcome. It's pure, and probably also returns NeverType?

if ($exprType->isCallable()->yes()) {
if (
$exprType->isCallable()->yes()
&& (!$exprType instanceof NeverType || $exprType->isExplicit())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would make more sense to me. It's basically never going to be called so a special class instead of TrivialParametersAcceptor would be welcome. It's pure, and probably also returns NeverType?

@ondrejmirtes
Copy link
Member

Well, or NeverType doesn't have to return yes for isCallable, I'm not sure why it does.

@staabm staabm marked this pull request as ready for review July 15, 2024 20:58
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

src/Type/NeverType.php Outdated Show resolved Hide resolved
public function testBug11207b(): void
{
$this->treatPhpDocTypesAsCertain = true;
$this->analyse([__DIR__ . '/data/bug-11207.php'], []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of pattern is usually done via a dataProvider.

@ondrejmirtes ondrejmirtes merged commit e1f64f2 into phpstan:1.11.x Jul 16, 2024
449 of 454 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants